<template>
<AppSuperRootAudit/>
</template>
<script>

import {onMounted, provide, ref} from "vue";
import AppSuperRootAudit from "@/views/lending/App/AppSuperRootAudit.vue";
import CryptoJS from "crypto-js";
export default {
  name: "BorrowingAuditView.vue",
  components:{AppSuperRootAudit},
  setup(){
    const cardSearchField = ref([
      {"borrowerName":"借阅人"},
      {"medicalRecord":"病案号"},
      {"hospitaLization":"住院号"},
      {"medicalRecordStatus":"病案状态"},
      {"dataPicker":"申请时间"},
    ])
    provide("cardSearchField",cardSearchField)

    //搜索框字段值控制
    const cardSearchValue = ref([
      {"medicalRecordStatus":["待审核","待出库","已出库"]}
    ])
    provide("cardSearchValue",cardSearchValue)
    //声明组件出处
    provide("LendingWhoView","BorrowingAuditView")
    //表单字段控制
    const mainFormField = ref([
      {'id':'btId'},//TODO:新增

      {'病案号':''},
      {'住院号':''},
      {'患者姓名':''},
      {'借阅人':'brBorrowerName'},
      {'借阅日期':'brEstimateBorrower'},
      {'归还日期':'brEstimateRestitution'},
      {'病案状态':'btMedicalRecordStatus'},
      {'登记时间':'brEnroll'},
      {'操作员':'brOperator'},
      {'借阅原因':'brReason'},
    ])
    provide("mainFormField",mainFormField)
    //病案状态的值规则控制控制
    const recordStatusValue = ref([
      {"0":'待审核'},
      {"1":'待出库'},
      {"2":'已出库'},
      {"3":'已取消'},
      {"4":'已驳回'},
    ])
    provide("recordStatusValue",recordStatusValue)
    //病案状态的颜色规则控制
    const recordStatusColor = ref([
      {"待审核":'color:#0468FF'},
      {"待出库":'color:#FA6A1C'},
      {"已出库":'color:#00A76F'},
      {"已取消":'color:#AAAAAA'},
      {'已驳回':'color:red'}
    ])
    provide("recordStatusColor",recordStatusColor)
    //rightShow:控制各组件所支持的功能规则
    const rightValue = ref([
      '查看','审核','取消登记','出库'
    ])
    provide("rightValue",rightValue)
    //rightShow:控制各组键所支持的功能展示规则
    const rightShow =ref([
      {'待审核':['审核','取消登记']},
      {'待出库':['查看','出库']},
      {'已出库':['查看']},
      {'已取消':['查看']},
      {'已驳回':['查看']},
    ])
    provide("rightShow",rightShow)
    //rightColor:控制各组件所支持功能的颜色展示规则
    const rightColor = ref([
      {"审核":'color:#0468FF'},
      {"取消登记":'color:#EC2121'},
      {"查看":'color:#0468FF'},
      {"出库":'color:#0468FF'},
      {'已驳回':'color:red'}
    ])
    provide("rightColor",rightColor)

    //密钥
    const secretKey = ref('')
    //catFieldShow:界面展示控制
    const catFieldShow = ref([
      {'targetName':'BorrowingAuditView'},
      {'title':'借阅详情'},
      {'patientInfo':['病案号','住院号','患者姓名','性别','年龄','住院病区','入院时间','出院时间','出院诊断']},
      {'borrowInfo':['借阅人','借阅日期','归还日期','操作员','登记时间','借阅原因']},
      {'specificFunctions':['审核通过','审核驳回','取消登记','出库']},
      {'specificColor':[{'已驳回':'color:red'},{'待审核':'color:#0468FF'},{'待出库':'color:#FA6A1C'},{'已出库':'color:#18CCD0'},{'已取消':'color:#AAAAAA'},
          {'审核通过':['background:#18CCD0','color:#FFFFFF']},{'审核驳回':['background:#EC2121','color:#FFFFFF']},
          {'取消登记':['background:#FFFFFF','color:#7F7F7F']},{'出库':['background:#0460FF','color:#FFFFFF']},
        ]},
      {'routerGoTo':[{'返回':'/lending/borrowingAudit/home'}]},
      //TODO:新增
      {'fieldMap':[
          {'病案号':''},
          {'住院号':''},
          {'患者姓名':''},
          {'借阅人':'brBorrowerName'},
          {'借阅日期':'brEstimateBorrower'},
          {'归还日期':'brEstimateRestitution'},
          {'病案状态':'btMedicalRecordStatus'},
          {'登记时间':'brEnroll'},
          {'操作员':'brOperator'},
          {'借阅原因':'brReason'},
        ]},
      {'recordStatusValue':[
          {"0":'待审核'},
          {"1":'待出库'},
          {"2":'已出库'},
          {"3":'已取消'},
          {"4":'已驳回'}
        ]},
      {'rightShow':[
          {'待审核':['审核通过','审核驳回','取消登记']},
          {'待出库':['出库']},
          {'已出库':[]},
          {'已取消':[]},
        ]}
    ])
    //catUrl:接口地址控制
    const catUrl = ref('/lending/borrowingAudit/record')
    //catControlShow:界面展示控制
    provide('catControlShow',[catUrl,secretKey,JSON.stringify(catFieldShow.value)])

    //newBrowControl：新建组件数据控制
    const newBrowControl = ref([
    ])
    //传输新建组件数据控制
    provide('newBrowControl',newBrowControl.value)

    // getSecretKey：更新秘钥规则
    function getSecretKey() {
      const currentTime = new Date().getTime();
      const baseKey = 'LendingRegisterView'; // 基础密钥
      const newSecretKey = `${baseKey}-${currentTime}`;
      secretKey.value = CryptoJS.MD5(newSecretKey).toString();
    }
    onMounted(()=>{
      // 页面加载时初始化 secretKey
      getSecretKey()
    })
    //定时更新secretKey
    setTimeout(getSecretKey, 30000)


  }


}
</script>



<style scoped>

</style>